home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / flkatck.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  12KB  |  375 lines

  1. /***************************************************************************
  2.  
  3. Flak Attack/MX5000 (Konami GX669)
  4.  
  5. Driver by:
  6.     Manuel Abadia <manu@teleline.es>
  7.  
  8. TO DO:
  9.     -What does 0x900X do? (Z80)
  10.  
  11. ***************************************************************************/
  12.  
  13. #include "driver.h"
  14. #include "cpu/z80/z80.h"
  15. #include "cpu/m6809/m6809.h"
  16. #include "vidhrdw/generic.h"
  17.  
  18. /* from vidhrdw/flkatck.c */
  19. int flkatck_vh_start(void);
  20. void flkatck_vh_screenrefresh(struct osd_bitmap *bitmap,int fullrefresh);
  21. WRITE_HANDLER( flkatck_k007121_w );
  22. WRITE_HANDLER( flkatck_k007121_regs_w );
  23.  
  24. extern unsigned char *k007121_ram;
  25. extern int flkatck_irq_enabled;
  26.  
  27. /***************************************************************************/
  28.  
  29. static void flkatck_init_machine( void )
  30. {
  31.     unsigned char *RAM = memory_region(REGION_SOUND1);
  32.     int bank_A, bank_B;
  33.  
  34.     bank_A = 0x20000 * 0;
  35.     bank_B = 0x20000 * 1;
  36.     K007232_bankswitch(0,RAM + bank_A,RAM + bank_B);
  37. }
  38.  
  39. static int flkatck_interrupt( void )
  40. {
  41.     if (flkatck_irq_enabled)
  42.         return HD6309_INT_IRQ;
  43.     else
  44.         return ignore_interrupt();
  45. }
  46.  
  47. static WRITE_HANDLER( flkatck_bankswitch_w )
  48. {
  49.     unsigned char *RAM = memory_region(REGION_CPU1);
  50.     int bankaddress = 0;
  51.  
  52.     /* bits 3-4: coin counters */
  53.     coin_counter_w(0,data & 0x08);
  54.     coin_counter_w(1,data & 0x10);
  55.  
  56.     /* bits 0-1: bank # */
  57.     bankaddress += 0x10000 + (data & 0x03)*0x2000;
  58.     if ((data & 0x03) != 0x03)    /* for safety */
  59.         cpu_setbank(1,&RAM[bankaddress]);
  60. }
  61.  
  62. static READ_HANDLER( flkatck_ls138_r )
  63. {
  64.     int data = 0;
  65.  
  66.     switch ((offset & 0x1c) >> 2){
  67.         case 0x00:    /* inputs + DIPSW #3 + coinsw */
  68.             if (offset & 0x02)
  69.                 data = readinputport(2 + (offset & 0x01));
  70.             else
  71.                 data = readinputport(4 + (offset & 0x01));
  72.             break;
  73.         case 0x01:    /* DIPSW #1 & DIPSW #2 */
  74.             if (offset & 0x02)
  75.                 data = readinputport(1 - (offset & 0x01));
  76.             break;
  77.     }
  78.  
  79.     return data;
  80. }
  81.  
  82. static WRITE_HANDLER( flkatck_ls138_w )
  83. {
  84.     switch ((offset & 0x1c) >> 2){
  85.         case 0x04:    /* bankswitch */
  86.             flkatck_bankswitch_w(0, data);
  87.             break;
  88.         case 0x05:    /* sound code number */
  89.             soundlatch_w(0, data);
  90.             break;
  91.         case 0x06:    /* Cause interrupt on audio CPU */
  92.             cpu_cause_interrupt(1,Z80_IRQ_INT);
  93.             break;
  94.         case 0x07:    /* watchdog reset */
  95.             watchdog_reset_w(0, data);
  96.             break;
  97.     }
  98. }
  99.  
  100. static struct MemoryReadAddress flkatck_readmem[] =
  101. {
  102.     { 0x0400, 0x041f, flkatck_ls138_r },            /* inputs + DIPS */
  103.     { 0x0800, 0x0bff, MRA_RAM },        /* palette */
  104.     { 0x1000, 0x1fff, MRA_RAM },                    /* RAM */
  105.     { 0x2000, 0x3fff, MRA_RAM },        /* Video RAM (007121) */
  106.     { 0x4000, 0x5fff, MRA_BANK1 },                    /* banked ROM */
  107.     { 0x6000, 0xffff, MRA_ROM },                    /* ROM */
  108.     { -1 }
  109. };
  110.  
  111. static struct MemoryWriteAddress flkatck_writemem[] =
  112. {
  113.     { 0x0000, 0x0007, flkatck_k007121_regs_w },        /* 007121 registers */
  114.     { 0x0400, 0x041f, flkatck_ls138_w },            /* bankswitch + counters + sound command */
  115.     { 0x0800, 0x0bff, paletteram_xBBBBBGGGGGRRRRR_w, &paletteram },/* palette */
  116.     { 0x1000, 0x1fff, MWA_RAM },                    /* RAM */
  117.     { 0x2000, 0x3fff, flkatck_k007121_w, &k007121_ram },            /* Video RAM (007121) */
  118.     { 0x4000, 0x5fff, MWA_BANK1 },                    /* banked ROM */
  119.     { 0x6000, 0xffff, MWA_ROM },                    /* ROM */
  120.     { -1 }
  121. };
  122.  
  123. static struct MemoryReadAddress flkatck_readmem_sound[] =
  124. {
  125.     { 0x0000, 0x7fff, MRA_ROM },                /* ROM */
  126.     { 0x8000, 0x87ff, MRA_RAM },                /* RAM */
  127.     { 0x9000, 0x9000, MRA_RAM },                /* ??? */
  128.     { 0x9001, 0x9001, MRA_RAM },                /* ??? */
  129.     { 0x9004, 0x9004, MRA_RAM },                /* ??? */
  130.     { 0xa000, 0xa000, soundlatch_r },            /* soundlatch_r */
  131.     { 0xb000, 0xb00d, K007232_read_port_0_r },    /* 007232 registers */
  132.     { 0xc001, 0xc001, YM2151_status_port_0_r },    /* YM2151 */
  133.     { -1 }
  134. };
  135.  
  136. static struct MemoryWriteAddress flkatck_writemem_sound[] =
  137. {
  138.     { 0x0000, 0x7fff, MWA_ROM },                    /* ROM */
  139.     { 0x8000, 0x87ff, MWA_RAM },                    /* RAM */
  140.     { 0x9000, 0x9000, MWA_RAM },                    /* ??? */
  141.     { 0x9001, 0x9001, MWA_RAM },                    /* ??? */
  142.     { 0x9006, 0x9006, MWA_RAM },                    /* ??? */
  143.     { 0xb000, 0xb00d, K007232_write_port_0_w },        /* 007232 registers */
  144.     { 0xc000, 0xc000, YM2151_register_port_0_w },    /* YM2151 */
  145.     { 0xc001, 0xc001, YM2151_data_port_0_w },        /* YM2151 */
  146.     { -1 }
  147. };
  148.  
  149.  
  150. INPUT_PORTS_START( flkatck )
  151.     PORT_START    /* DSW #1 */
  152.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
  153.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  154.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  155.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  156.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  157.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  158.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  159.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  160.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  161.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  162.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  163.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  164.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  165.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  166.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  167.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  168.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  169.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  170.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  171.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  172.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  173.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  174.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  175.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  176.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  177.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  178.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  179.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  180.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  181.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  182.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  183.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  184.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  185.     //PORT_DIPSETTING(    0x00, "Invalid" )
  186.  
  187.     PORT_START    /* DSW #2 */
  188.     PORT_DIPNAME( 0x03, 0x01, DEF_STR( Lives ) )
  189.     PORT_DIPSETTING(    0x03, "1" )
  190.     PORT_DIPSETTING(    0x02, "2" )
  191.     PORT_DIPSETTING(    0x01, "3" )
  192.     PORT_DIPSETTING(    0x00, "5" )
  193.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
  194.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  195.     PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
  196.     PORT_DIPNAME( 0x18, 0x10, DEF_STR( Bonus_Life ) )
  197.     PORT_DIPSETTING(    0x18, "30000 70000" )
  198.     PORT_DIPSETTING(    0x10, "40000 80000" )
  199.     PORT_DIPSETTING(    0x08, "30000" )
  200.     PORT_DIPSETTING(    0x00, "40000" )
  201.     PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )
  202.     PORT_DIPSETTING(    0x60, "Easy" )
  203.     PORT_DIPSETTING(    0x40, "Normal" )
  204.     PORT_DIPSETTING(    0x20, "Difficult" )
  205.     PORT_DIPSETTING(    0x00, "Very difficult" )
  206.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  207.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  208.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  209.  
  210.     PORT_START    /* DSW #3 */
  211.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
  212.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  213.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  214.     PORT_DIPNAME( 0x02, 0x02, "Upright Controls" )
  215.     PORT_DIPSETTING(    0x02, "Single" )
  216.     PORT_DIPSETTING(    0x00, "Dual" )
  217.     PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
  218.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  219.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  220.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  221.     PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
  222.  
  223.     PORT_START    /* COINSW & START */
  224.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  225.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  226.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )    /* service */
  227.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
  228.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
  229.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
  230.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
  231.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
  232.  
  233.     PORT_START    /* PLAYER 1 INPUTS */
  234.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  235.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  236.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  237.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  238.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  239.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  240.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
  241.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
  242.  
  243.     PORT_START    /* PLAYER 2 INPUTS */
  244.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  245.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  246.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  247.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  248.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  249.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  250.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
  251.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
  252. INPUT_PORTS_END
  253.  
  254. static struct GfxLayout gfxlayout =
  255. {
  256.     8,8,
  257.     0x80000/32,
  258.     4,
  259.     { 0, 1, 2, 3 },
  260.     { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4 },
  261.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  262.     32*8
  263. };
  264.  
  265. static struct GfxDecodeInfo gfxdecodeinfo[] =
  266. {
  267.     { REGION_GFX1, 0, &gfxlayout, 0, 32 },
  268.     { -1 } /* end of array */
  269. };
  270.  
  271. static struct YM2151interface ym2151_interface =
  272. {
  273.     1,
  274.     3579545,    /* 3.579545 MHz */
  275.     { YM3012_VOL(100,MIXER_PAN_LEFT,100,MIXER_PAN_RIGHT) },
  276.     { 0 },
  277. };
  278.  
  279. static void volume_callback0(int v)
  280. {
  281.     K007232_set_volume(0,0,(v >> 4) * 0x11,0);
  282.     K007232_set_volume(0,1,0,(v & 0x0f) * 0x11);
  283. }
  284.  
  285. static struct K007232_interface k007232_interface =
  286. {
  287.     1,            /* number of chips */
  288.     { REGION_SOUND1 },        /* memory region */
  289.     { K007232_VOL(50,MIXER_PAN_CENTER,50,MIXER_PAN_CENTER) },    /* volume */
  290.     { volume_callback0 }    /* external port callback */
  291. };
  292.  
  293.  
  294. static struct MachineDriver machine_driver_flkatck =
  295. {
  296.     {
  297.         {
  298.             CPU_HD6309,    /* HD63C09EP */
  299.             3000000,    /* 24/8 MHz*/
  300.             flkatck_readmem,flkatck_writemem,0,0,
  301.             flkatck_interrupt,1
  302.         },
  303.         {
  304.             CPU_Z80,    /* NEC D780C-1 */
  305.             3579545,    /* 3.579545 MHz */
  306.             flkatck_readmem_sound, flkatck_writemem_sound,0,0,
  307.             ignore_interrupt,0    /* IRQs triggered by the 6309 */
  308.         }
  309.     },
  310.     60, DEFAULT_60HZ_VBLANK_DURATION,
  311.     10,
  312.     flkatck_init_machine,
  313.  
  314.     /* video hardware */
  315.     37*8, 32*8, { 0*8, 35*8-1, 2*8, 30*8-1 },
  316.     gfxdecodeinfo,
  317.     512, 512,
  318.     0,
  319.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  320.     0,
  321.     flkatck_vh_start,
  322.     0,
  323.     flkatck_vh_screenrefresh,
  324.  
  325.     /* sound hardware */
  326.     SOUND_SUPPORTS_STEREO,0,0,0,
  327.     {
  328.         {
  329.             SOUND_YM2151,
  330.             &ym2151_interface
  331.         },
  332.         {
  333.             SOUND_K007232,
  334.             &k007232_interface
  335.         }
  336.     }
  337. };
  338.  
  339.  
  340.  
  341. ROM_START( mx5000 )
  342.     ROM_REGION( 0x18000, REGION_CPU1 )        /* 6309 code */
  343.     ROM_LOAD( "r01",          0x010000, 0x006000, 0x79b226fc )/* banked ROM */
  344.     ROM_CONTINUE(             0x006000, 0x00a000 )            /* fixed ROM */
  345.  
  346.     ROM_REGION( 0x10000, REGION_CPU2 )        /* 64k for the SOUND CPU */
  347.     ROM_LOAD( "m02.bin",        0x000000, 0x008000, 0x7e11e6b9 )
  348.  
  349.     ROM_REGION( 0x080000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  350.     ROM_LOAD( "mask4m.bin",        0x000000, 0x080000, 0xff1d718b )/* tiles + sprites */
  351.  
  352.     ROM_REGION( 0x040000, REGION_SOUND1 )    /* 007232 data (chip 1) */
  353.     ROM_LOAD( "mask2m.bin",        0x000000, 0x040000, 0x6d1ea61c )
  354. ROM_END
  355.  
  356. ROM_START( flkatck )
  357.     ROM_REGION( 0x18000, REGION_CPU1 )        /* 6309 code */
  358.     ROM_LOAD( "gx669_p1.16c", 0x010000, 0x006000, 0xc5cd2807 )/* banked ROM */
  359.     ROM_CONTINUE(             0x006000, 0x00a000 )            /* fixed ROM */
  360.  
  361.     ROM_REGION( 0x10000, REGION_CPU2 )        /* 64k for the SOUND CPU */
  362.     ROM_LOAD( "m02.bin",        0x000000, 0x008000, 0x7e11e6b9 )
  363.  
  364.     ROM_REGION( 0x080000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  365.     ROM_LOAD( "mask4m.bin",        0x000000, 0x080000, 0xff1d718b )/* tiles + sprites */
  366.  
  367.     ROM_REGION( 0x040000, REGION_SOUND1 )    /* 007232 data (chip 1) */
  368.     ROM_LOAD( "mask2m.bin",        0x000000, 0x040000, 0x6d1ea61c )
  369. ROM_END
  370.  
  371.  
  372.  
  373. GAME( 1987, mx5000,  0,      flkatck, flkatck, 0, ROT90, "Konami", "MX5000" )
  374. GAME( 1987, flkatck, mx5000, flkatck, flkatck, 0, ROT90, "Konami", "Flak Attack (Japan)" )
  375.